package pl.perseus.dao;
 
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import pl.perseus.model.StudentClasses;

@Repository
public class StudentClassesDao extends BaseDao<StudentClasses> implements IStudentClassesDao{
 
	
	public StudentClassesDao() {
		super("StudentClasses");
	}

	@Override
    public StudentClasses selectByIdStudentClasses(Long id) {
    	Map<String, Object> map = new HashMap<String, Object>();
    	map.put("id", id);
        return queryForObject("getByIdStudentClasses", map);
    }
	
	@Override
	public StudentClasses insertStudentClasses(StudentClasses StudentClasses){
		return insertBean("insertStudentClasses", StudentClasses);
	}
	
	@Override
	public StudentClasses deleteStudentClasses(StudentClasses StudentClasses){
		return insertBean("deleteStudentClasses", StudentClasses);
	}
	
	@Override
	public StudentClasses getByStudentAndClasses(StudentClasses studentClasses){
		Map<String, Object> map = new HashMap<String, Object>();
    	map.put("id_student", studentClasses.getId_student());
    	map.put("id_classes", studentClasses.getId_classes());
    	List<StudentClasses> list =  queryForList("getByStudentAndClasses", map);
    	return list.isEmpty() ? null : list.get(0);    	
	}
	
}
